package com.xc.controller;

import com.xc.dto.ResultDTO;
import com.xc.entity.NavEntity;
import com.xc.entity.RoleNavEntity;
import com.xc.entity.RoleNavManyEntity;
import com.xc.service.NavService;
import com.xc.service.RoleNavService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

//restful 增加post，修改put，删除delete，查询get
@RestController
@RequestMapping("/xc/roleNav")
@Api(tags = "角色导航管理")
public class RoleNavController {
    @Autowired
    private RoleNavService roleNavService;

//    @ApiOperation(value = "角色导航增加",notes = "角色导航增加接口的说明:如果一次性增加多个权限，则roleId参数为0，只需要将数据放入list即可，")
//    @PostMapping()
//    public ResultDTO add(@RequestBody RoleNavEntity roleNavEntity) {
//        return roleNavService.add(roleNavEntity);
//    }
    @ApiOperation(value = "角色导航增加",notes = "角色导航增加接口的说明:如果一次性增加多个权限，则roleId参数为0，只需要将数据放入list即可，")
    @PostMapping()
    public ResultDTO add(@RequestBody List<RoleNavManyEntity> list) {
        return roleNavService.add(list);
    }
//    @ApiOperation(value = "角色导航修改",notes = "给指定的角色赋值权限")
//    @PutMapping()
//    public ResultDTO update(RoleNavEntity roleNavEntity) {
//        return roleNavService.update(roleNavEntity);
//    }

//    @ApiOperation("根据id进行删除角色导航数据")
//    @DeleteMapping("/{id}")
//    public ResultDTO delete(RoleNavEntity roleNavEntity) {
//        return roleNavService.delete(roleNavEntity);
//    }

    @ApiOperation("查询所有角色导航数据")
    @GetMapping()
    public ResultDTO findAll(RoleNavEntity roleNavEntity) {
        return roleNavService.findAll(roleNavEntity);
    }

    @ApiOperation("根据id查询角色导航")
    @GetMapping("/{id}")
    public ResultDTO findById(RoleNavEntity roleNavEntity) {
        return roleNavService.findById(roleNavEntity);
    }

    @ApiOperation("查询角色导航总条数")
    @GetMapping("/count")
    public ResultDTO count(RoleNavEntity roleNavEntity) {
        return roleNavService.count(roleNavEntity);
    }
}
